home *** CD-ROM | disk | FTP | other *** search
-
-
- RPN CALCULATOR PROGRAM - VERSION 1.41
- Copyright (c) 1984,85 Tom Ginn
-
- NAME:
-
- RPN
-
- COMMAND STRING:
-
- RPN [RAMFSBn=x]
-
- SUMMARY:
-
- RPN is a calculator program written in C (mostly) and compiled with the
- DeSmet C development package. It runs on the IBM PC under PC-DOS and
- hopefully on most IBM PC compatible machines using PC-DOS or MS-DOS.
- Either color or monochrome display may be used. RPN uses up about 54K
- of memory so you will need total system memory of at least 96K to run
- it, and more if you plan to install it in the background. The features
- of the program include:
-
- 1. Reverse Polish (RPN) or algebraic operation
- 2. Operation in number bases from 2 to 16
- 3. Easy number base conversion
- 4. Fixed point or Scientific (base 10 only) notation
- 5. Financial calculations
- 6. Summation, mean & standard deviation
- 7. User defined macro keypoke sequences
- 8. 8087 math chip support
- 9. Trig, Log, Exponential operations
- 10. Calendar display
- 11. Ability to remain memory resident in the background
- 12. Ability to use BIOS routines or go directly to
- screen memory for faster output.
-
- Please note: the memory resident and direct screen output features
- depend on IBM-PC screen memory and video mode compatibility. While
- vanilla RPN has worked on every PC compatible I've tried it on
- including PC jr, and I have not yet had any problems running the memory
- resident and direct screen features on the machines I've been able
- to try, there is still room for these features to fail on some
- machines.
-
- PROGRAM DISTRIBUTION:
-
- RPN is distributed on a single sided 8 sector MS-DOS/PC-DOS
- diskette containing the following files:
-
- 1) RPN.EXE - The calculator program with software floating point
- for systems without the 8087 math co-processor.
- 2) RPN7.EXE - The calculator program with 8087 floating point
- support for systems with the 8087 math co-processor.
- 3) RPN.DOC - This documentation file.
- 4) RPN.R1, RPN.A1 and RPN.R2 - Sample macro files in the format
- saved by the macro save operation.
-
- We are all familiar with the current marketing strategy for software
- products: use copy protection, accept the fact that there will be
- unauthorized copies made, and charge an arm and a leg to try to
- compensate for it. Well, with RPN there is no copy protection, all
- copies are authorized, and, by the way, you can keep your leg and most
- of your arm.
-
- You are welcome to make copies of RPN for your personal use and
- encouraged to pass it along to your friends. If you find RPN useful
- and decide to keep a copy, I will hope to receive a small honorarium
- from you. I suggest $10.00 as an appropriate amount but leave the
- final decision to you. Procrastination is my worst enemy in this
- endeavor, so please don't put it off. Send to:
-
- Tom Ginn
- P.O. Box 24842
- San Jose, CA 95154-4842
-
- If you prefer, you may order a program diskette of the current revision
- level from me for $15.00. Orders from California residents should include
- sales tax.
-
- This method of software distribution can succeed only with your
- co-operation. If you would like to see greater use of this medium to
- distribute useful software at minimal cost, please support this
- program and others like it.
-
- Please Note....
- ** When you copy RPN be sure to pass along all the files.
- ** Do not circulate modified copies of RPN.
- ** Do not remove this message from the RPN files.
-
- While I have made every effort to locate and remove insect life from
- this program, there is an unwritten law that says any non-trivial
- software package will have bugs, and I don't expect this program to be
- exempt from the laws of nature. Therefore I must distribute RPN "as
- is" to be employed at the user's risk, and can assume no liability for
- any losses or damages of any kind resulting from use or misuse of the
- program. No express or implied warranties regarding merchantability or
- fitness of use shall apply.
-
- Comments, suggestions, and/or reports of encounters with any remaining
- insect life may be directed to the author at the above address. If
- your correspondence requires a reply, please enclose a self addressed
- stamped envelope to help speed things up. Thank you for your interest
- in my calculator program. I hope you will find it as useful as I do.
-
- DESCRIPTION:
-
- RPN is executed by typing its name and optional parameters specifying
- the desired mode of operation in response to the prompt from the
- MS-DOS command processor:
-
- RPN [RAMFSBn=x] (RPN7 for the 8087 load)
-
- Where:
-
- R - RPN mode. The program will run in RPN mode and
- will attempt to load a macro file RPN.R0 (this
- is the default mode).
-
- A - Algebraic mode. The program will run in algebraic
- mode and will attempt to load a macro file RPN.A0.
-
- M - Override color attributes with white on black.
-
- F - Fast mode. This parameter causes the screen output
- to bypass the BIOS and go direct to screen memory.
- You'll be amazed at the difference.
-
- S - Stay resident in memory. RPN will install itself
- in memory and be ready to run when it sees a
- special activation code from the keyboard.
- When running resident, fast mode is implied.
-
- B - Blink scroll handling. You may also be amazed by the
- amount of noise fast mode makes on your screen if you
- have the IBM color card or a similar one that doesn't
- like to have the cpu access screen memory during
- display. If so, use this option when you are using F
- or S to tell RPN to synchronize output to the screen
- with the horizontal retrace so it doesn't show. It
- slows down fast mode a bit but it's worth it.
-
- =x - The default activation code is CTRL-ALT-C but this
- parameter will change it to the letter you specify
- immediately following the = sign.
-
- n - Macro file number from 0-9. Allows you to specify
- the macro file number to be loaded. See section
- on saving macros for more on macro files.
-
- Examples:
-
- RPN vanilla RPN
- RPN7 8087 load of RPN
- RPN A algebraic mode
- RPN AF algebraic and fast modes
- RPN S memory resident
- RPN SB memory resident with blink scroll handling
- RPN S=Z memory resident with CTRL-ALT-Z activation
- RPN F5 fast mode, load macro file RPN.R5
-
- Please note: If the 8087 load of RPN is executed on a system without
- the 8087 co-processor present it will hang the computer and you will
- have to re-boot (CTRL-ALT-DEL will do it). If the non-8087 load is
- executed on a machine with an 8087 installed there are no ill effects
- but you will not take advantage of the 8087 speed.
-
- If no parameters are specified the program will determine the operating
- mode by the macro files that are present. It looks first for RPN.R0
- and if it is present then RPN mode is used and RPN.R0 is loaded. If it
- doesn't find RPN.R0 then it looks for RPN.A0 and if it is found then
- algebraic mode is used and RPN.A0 is loaded. If neither macro file is
- found the program will default to RPN mode with predefined color
- attributes. You may specify a macro file number to determine the
- macro file that is used instead of the default 0.
-
- The program execution is terminated by poking the Escape key (ESC).
- If RPN is running as a normal program it will return control to the
- operating system. If RPN is running as a background program entered
- by the CTRL-ALT-whatever activation code, it will return to the
- interrupted program.
-
- In the default RPN (Reverse Polish Notation) mode, the program behaves
- in many respects like a Hewlett-Packard RPN calculator with a 4
- register stack ( x, y, z, & t registers ), 10 memory registers, and a
- last x register. All 4 registers of the stack are displayed on the
- screen and the calculations operate on the x register only or on the x
- and y registers, leaving the result in the x register or x and y
- registers.
-
- The following keys are used to execute the calculator's operations.
- A short description will be given here for each key used, and more
- detailed information on some operations will appear later in this
- manual. Poking a key for which no operation is defined just rings a
- bell at you.
-
- 0-9 Number entry.
-
- A-F Hex number entry.
-
- . Decimal point entry.
-
- + y+x Since some keyboards don't have a plus you can get to
- without the shift key, TAB is equivalent to +.
-
- - y-x
-
- / y/x
-
- * y*x Since some keyboards don't have an * you can get to
- without the shift key, COMMA is equivalent to *.
-
- % y%x Remainder of y/x or y mod x. This operation is limited
- to integer operands less than 2,147,483,648 (2^31).
-
- ^ Pow(y,x) y raised to the x power.
-
- & y AND x Logical bitwise AND of y and x register values.
- This operation is limited to integer operands less than
- 2,147,483,648 (2^31).
-
- | y OR x Logical bitwise Inclusive OR of y and x register values.
- This operation is limited to integer operands less than
- 2,147,483,648 (2^31).
-
- $ y XOR x Logical bitwise Exclusive OR of y and x register values.
- This operation is limited to integer operands less than
- 2,147,483,648 (2^31).
-
- ~ Negate x
-
- ! x factorial
-
- \ Alternate operation prefix. When this key is poked, "shift" is
- written on the message line to signify alternate interpretation
- of the next key poked.
-
- # Macro function flag. This character, inserted at the beginning
- of a macro, indicates that you want the macro treated as a
- function which returns a value to the x register.
-
- [] Macro comment brackets. Characters between brackets in a macro
- string will be ignored. This allows short comments to be
- included in saved macro strings.
-
- = Enter key (RPN mode) or Equals key (Algebraic mode). Note
- several alternates are interpreted as ENTER for keypoking ease.
-
- CR Enter key (RPN mode) or Equals key (Algebraic mode). The CR
- (carriage return) key generates the same code as Control-M
- and on various keyboards may be labeled "RETURN", "CR",
- or "ENTER".
-
- LF Enter key (RPN mode) or Equals key (Algebraic mode). The LF
- (line feed) key generates the same code as Control-J and on
- various keyboards may be labeled "LINE FEED" or "NEW LINE"
- or may not be present at all.
-
- space Enter key (RPN mode) or Equals key (Algebraic mode).
-
- F1 Function keys F1-F10 execute assigned macros.
-
- \F1 Function keys F1-F10 copy the macro function key definition to
- the scratch string for macro editing. If the macro string is
- defined it is displayed on the message line.
-
- a Screen setup for normal calculator mode. Can also be used to
- rewrite the calculator screen in case the display gets trashed.
- Displays the status line, register stack, message line, and
- calculator help text.
-
- \a Screen setup for financial mode. Enables the financial
- operation keys. Displays status line, register stack, message
- line, financial registers, and financial help text. The normal
- calculator functions are still available, too.
-
- b Set number base. The calculator is capable of doing most of
- its numeric input and output in any number base from 2 to 16.
-
- \b Memory display mode. An alternate display screen in normal
- calculator mode shows the 10 memory registers in place of the
- help text in the lower half of the screen.
-
- c Cos(x) Cosine of x.
-
- \c Arccos(x) - Angle whose cosine is x.
-
- d Set display format. The display format may be set to either
- fixed point or scientific notation and the number of places
- right of the decimal point may be varied from 0 to 9.
-
- \d Set degrees mode for trig functions and rectangular/polar conversions.
-
- \D Debug toggle. This turns on (or off) some debugging messages
- that were handy enough to keep available. One is output of the
- x and y registers so their internal 64 bit storage format can
- be seen as 4 hex words. Another is intermediate values of the
- iterative process used to calculate interest rate in the
- financial mode.
-
- e Enter exponent. For entry of numbers in scientific notation
- when number base is decimal. '-' or '~' changes sign of
- exponent. Any key not '0'-'9', '-' or '~' terminates entry and
- is interpreted as the next operation key.
-
- \e Screen setup for summation mode. Displays status line, register
- stack, message line, summation registers, and summation help text.
- Provides for summation of a number of values entered into the
- x register and computation and display of the mean and standard
- deviation.
-
- f Frac(x) Keep fractional part of x. The integer part of the
- floating point number in the x register is discarded.
-
- \f Calendar display mode. This draws the calendar screen and
- switches over to the calendar commands, which are described
- later. In calendar mode the normal calculator commands
- are disabled.
-
- i Int(x) Keep integer part of x. The fractional part of the
- floating point number in the x register is discarded.
-
- k Rectangular to polar. The x and y registers are assumed to
- contain rectangular x and y coordinates, respectively, and are
- converted to polar coordinates (r, theta). The resulting r is
- left in the x register and theta is left in the y register.
- If you use this while in algebraic mode, you will have to use
- the "x" key (exchange) to load the y register.
-
- \k Polar to rectangular. This is the inverse of the rectangular
- to polar conversion. Again, in algebraic mode the "x" key is
- used to load the y register.
-
- l Log10(x) Log of x to base 10.
-
- \l Pow(10,x) Raise 10 to the x power (antilog of x).
-
- L Last x. Whenever an operation is executed which calculates a
- result and leaves it in the x register, the old value contained
- in the x register is saved in the "last x" register. The last
- x key retrieves the saved value and pushes it on the stack.
-
- m Execute macro.
-
- \m Define macro.
-
- M Edit macro.
-
- \M Save macros in a disk file.
-
- n Ln(x) Natural log of x.
-
- \n Exp(x) Raise e to the x power (exponential of x).
-
- o 1/x Reciprocal of x.
-
- p Pi Push Pi on the stack.
-
- q Sqrt(x) Square root of x.
-
- \q x * x Square of x.
-
- r Recall from memory register and push on the stack. This operation
- is also used to move financial and summation register values to
- the operational stack so they can be used in normal calculations.
-
- R Recall from memory register. Same as "r" for convenience.
-
- \r Set radians mode for trig functions and rectangular/polar conversions.
-
- s Sin(x) Sine of x.
-
- \s Arcsin(x) Angle whose sine is x.
-
- t Tan(x) Tangent of x.
-
- \t Arctan(x) Angle whose tangent is x.
-
- v Rotate down.
-
- V Rotate down. Same as "v" for convenience.
-
- \v Rotate up.
-
- \V Rotate up. Same as "\v" for convenience.
-
- w Write x in memory register. Optionally add x to memory,
- subtract x from memory, multiply x by memory, or divide x into
- memory, storing the result into memory.
-
- W Write x in memory register. Same as "w" for convenience.
-
- x Exch(y,x) Exchange x and y register values.
-
- X Exch(y,x) Same as "x" for convenience.
-
- \x Clear the summation registers.
-
- \X Clear the summation registers. Same as "\x" for convenience.
-
- y Clear financial registers.
-
- Y Clear financial registers. Same as "y" for convenience.
-
- \y Clear memory registers.
-
- \Y Clear memory registers. Same as "\y" for convenience.
-
- z Clear x register.
-
- Z Clear x register. Same as "z" for convenience.
-
- \z Clear stack.
-
- \Z Clear stack. Same as "\z" for convenience.
-
- The following operations make up the finiancial section of the
- calculator. The Enter/Compute and \p keys are disabled in normal
- calculator mode and are enabled when you change to the financial mode.
-
- \a Redraw financial screen.
-
- I Enter/compute Interest Rate.
-
- N Enter/compute Number of Periods.
-
- P Enter/compute Payment.
-
- S Enter/compute Start (Present) value (PV).
-
- T Enter/compute Terminal (Future) value (FV).
-
- \p Set the financial period to use. This will be day, week,
- month, quarter, or year. If it makes sense to do so, the
- number of periods will be converted to the new period
- and the new periodic payment will be calculated.
-
- r Recall. "r" followed by the register letter is used to move a
- value from a financial register to the operational stack so it
- can be used in normal calculations.
-
- y Clear financial registers.
-
- The following operations make up the summation section of the
- calculator.
-
- \e Redraw screen.
-
- u Summation (+). The value from the x register is summed in the
- summation registers and the mean and standard deviation values
- are computed and displayed.
-
- \u Summation Correction (-). If an erroneous value is summed with
- the "u" operation it can be removed from the summation by entering
- the value to be removed in the x register and using "\u".
-
- \x Clear the summation registers.
-
- r Recall. "r" followed by the register letter is used to move a
- value from a summation register to the operational stack so it
- can be used in normal calculations.
-
- The following commands are available in calendar display mode. When
- the calendar display mode is active, the rest of the calculator
- functions are disabled.
-
- 0-9 Enter a year. Each time a digit is typed the existing year is
- multiplied by 10, the new digit is entered into the ones position,
- and a calendar is generated. The calendar has a range from year
- 0001 to 10000.
-
- F1/F2 Go back/forward 1 month. For convenience the left arrow and
- right arrow cursor motion keys are also plugged into these
- functions.
-
- F3/F4 Go back/forward 1 year. For convenience the down arrow and up
- arrow cursor motion keys are also plugged into these functions.
-
- F5/F6 Go back/forward 1 decade (10 years).
-
- F7/F8 Go back/forward 1 century (100 years).
-
- Home Displays the calendar for today's date. Today is determined by
- reading the system time so you should set your clock for this
- to come out right. The "t" key is also plugged into this action.
-
- End Leave calendar mode. The program will re-enter the calculator
- mode that was active when calendar mode was started up. The "x"
- key is also plugged into this action.
-
- RPN vs. ALGEBRAIC
-
- You will see the difference between RPN mode and algebraic mode in
- operations which act on two operands(+ - * / % ^ & | $). Reverse
- Polish Notation requires that you first put the numbers to be operated
- on into the stack and then poke the appropriate key to inform the
- program what you want it to do. The "Enter" key is used to separate
- the entry of the two numbers. To multiply 2 times 3 the keypoke
- sequence is:
-
- 2 Enter 3 *
-
- As you poke the keys, you will see the stack be updated on the screen
- with each keypoke. These are the stack displays you will see during
- the example calculation:
-
- 2 Enter 3 *
- t: 0.00 0.00 0.00 0.00 0.00
- z: 0.00 0.00 0.00 0.00 0.00
- y: 0.00 0.00 2.00 2.00 0.00
- x: 0.00 2.00 2.00 3.00 6.00
-
- A slightly more complicated example (2 * 3 + 4 * 5) adds another
- product to the result of the first product and shows the use of RPN and
- the register stack to preserve an intermediate result for later use.
- We start off with the result of the first product remaining in the x
- register, use the same procedure to multiply 4 times 5, and then poke
- the "+" key to add the two product results:
-
- 4 Enter 5 * +
- t: 0.00 0.00 0.00 0.00 0.00 0.00
- z: 0.00 0.00 6.00 6.00 0.00 0.00
- y: 0.00 6.00 4.00 4.00 6.00 0.00
- x: 6.00 4.00 4.00 5.00 20.00 26.00
-
- If you are uncomfortable with the RPN mode, the calculator may be run
- in its algebraic mode. In algebraic mode only the x and y registers
- are displayed and operation is modified so the keypoke sequence to
- multiply 2 times 3 becomes the familiar:
-
- 2 * 3 =
-
- In algebraic mode the ability to preserve an intermediate result on the
- stack is gone but the memory registers can be easily used instead. To
- use the rectangular/polar conversion in algebraic mode it is necessary
- to use the exchange function ("x") to get the y register loaded with
- its parameter.
-
- MEMORY RESIDENT MODE and FAST MODE
-
- RPN can be run either as a normal program or as a resident background
- utility. You install it in the background by executing it with the "s"
- parameter on the command line. Instead of the normal calculator screen
- you will see something like this:
-
- A> RPN S
-
- RPN/Algebraic Calculator - Version 1.41
- Copyright (c) 1984,85 Tom Ginn
-
- Installed in background. Activate with CTRL-ALT-C
- when the running program is waiting for key input.
-
- A>
-
- From this point on you may get into RPN by typing the activation code
- whenever (almost) the running program is expecting keyboard input. I
- say "almost" because the command.com command line input can only be
- interrupted if it is a fresh prompt and no other characters have been
- typed before the activation code. RPN will silently refuse to activate
- itself if command.com is active and you have typed any characters in
- response to the command prompt. In this case all you need to do is type
- CTRL-C to clear the entered characters and get a fresh prompt.
-
- You may interrupt any standard IBM-PC video mode and return to it when
- you exit RPN. Some cautions should be observed, however:
-
- 1. If you have a video card with non-standard video modes,
- DON'T interrupt a non-standard mode. RPN doesn't
- know how to restore anything but standard modes.
-
- 2. If you have a mouse running and a mouse cursor on the
- screen you interrupt, don't move the mouse while
- RPN is active. The mouse interrupt handler is still
- running and trying to update screen memory and you
- may see it on the RPN screen. Your interrupted screen
- may not be quite as you left it either.
-
- 3. If you have two or more background routines installed, it's
- best not to interrupt one to enter another. RPN and some
- other background programs change video mode by programming
- the video card directly rather than call the BIOS to change
- the mode. I found this to be necessary to keep a mouse
- cursor from getting lost. The video mode may not be properly
- restored when returning to another background program.
-
- 4. If you use RPN in the background along with Borland's
- Sidekick, install RPN before Sidekick. You won't have any
- trouble getting to Sidekick with the CTRL-ALT combination.
- To get RPN, hold CTRL-ALT down until Sidekick's menu window
- goes away before pressing the "C" to get RPN.
-
- If you install RPN in the background of a PC jr, you will find that
- it only allows the activation sequence to proceed if the computer is
- already in the video mode required (mode 2 or 3). You can't interrupt
- any other mode because RPN does not handle the mode changes on the jr.
- I think most jr's will not have enough memory available to install
- background utilities anyway.
-
- If you find it necessary or desirable to have RPN use a different
- activation code than the default CTRL-ALT-C, you can use the =x
- parameter to specify any letter of the alphabet to replace the default
- C. For example, to install RPN with an activation code of CTRL-ALT-R,
- install RPN in memory with the command:
-
- RPN S=R
-
- The "fast" mode is required by and automatically set by the resident
- mode. However, "fast" mode is available by itself when the program
- is executed normally by using the "F" parameter on the command line.
- Try it both ways. The difference is interesting.
-
- Please note: the memory resident and direct screen output features
- depend on IBM-PC screen memory and video mode compatibility. While
- vanilla RPN has worked on every PC compatible I've tried it on
- including PC jr, and I have not yet had any problems running the memory
- resident and direct screen features on the few machines I've been able
- to try, there is still room for these features to fail on some
- machines.
-
- NUMBER BASES
-
- As previously mentioned, the calculator will operate in any number base
- from 2 to 16. The number base is set by the "b" key, which will ask
- for an input base and a conversion base.
-
- The input base determines the range of keys that will be accepted from
- the keyboard, the conversion of input data to the computer's internal
- format, and the number base of the primary register displays on the
- screen. The conversion base, if different from the input base,
- determines the base for a second display of the x and y registers which
- is put on the screen to the right of the primary displays.
-
- The program comes up with both bases set to 10 for use as a decimal
- calculator. The status line near the top of the screen will say "Base
- 10". To do number base conversions from base 10 to base 16 (for
- example), use the "b" key to set the input base to 10 and the
- conversion base to 16. The status line will say "Base 10:16" and there
- will be two displays of the x and y registers. The left display is in
- base 10 and the right display is in base 16.
-
- FINANCIAL MODE
-
- The calculator's financial mode implements the standard formulae for
- computing one of five related values from the known values of the other
- four. The financial mode screen displays the registers reserved for
- these values on the lower half of your screen. They are:
-
- N: The number of periods.
- I: The annual interest rate in percent (APR).
- S: The starting or present value.
- T: The terminal or future value.
- P: The periodic payment.
-
- Using this mode you can figure out mortgage payments, accumulation of
- savings, annuities, and several other kinds of financial situations
- that fit the pattern.
-
- When you enter financial mode the first time the default period will be
- months. You can change the period to days, weeks, months, quarters, or
- years with the \p function. This allows the program to internally
- compute the periodic interest rate from the annual interest rate you
- enter into the interest register.
-
- Let's start off with the good ol' home mortgage payment calculation as
- an example. First you would get into financial mode by keying in "\a"
- and making sure the period is set to "months". You then enter the
- known values into the financial registers by keying the value in so it
- appears in the x register on the stack and then poke the appropriate
- Enter/Compute operation key from the financial help menu at the bottom
- of the screen. The program watches numeric input and decides to do
- Enter if you have just keyed in a number and Compute if no number has
- been keyed in since the last Enter.
-
- For a 30 year mortgage, key in "360N".
- For a 13.5% annual interest rate, Key in "13.5I".
- For a $90,000 loan amount, key in "90000S".
- For a fully amortized loan, the future value is 0 so
- key in "0T" if the register does not already
- contain 0.
- To compute the monthly payment, key in "P". The calculator
- will compute and display "-1030.87".
-
- Note the value of the payment is negative. Since this calculation was
- done from the point of view of the borrower the loan amount is
- positive, representing an amount being paid in at the beginning of the
- loan. The negative payment signifies an amount being periodically paid
- out from the point of view of the calculation. If we looked at the
- loan from the lender's point of view the signs would be reversed. Now
- that these values have been entered, try entering different interest
- rates and recomputing the payment to see the effect.
-
- Remember that any one of these variables can be computed from the other
- four. In the above example, suppose you could afford a $900 monthly
- payment and use the program to determine what interest rate you would
- have to shop for.
-
- For a $900 payment, key in "900~P". The "~" changes
- the sign of the payment to negative, which is
- necessary for our point of view.
- To compute the interest rate, key in "I". The program will
- go away and work for a while on this one but it will
- come back in a few seconds with the answer, "11.63".
-
- For the next example, we'll do the IRA (Individual Retirement Account)
- routine to see how savings accumulation works. Since we are going to
- enter a complete new set of numbers, first use "y" to clear the
- financial registers. Now, lets assume you want to put $2000 per year
- into your IRA for 30 years and you will do it by depositing $500 each
- quarter (3 months). Key in "\p" to change the period and answer the
- "What period?" question with a "q" for "quarter". Now enter the known
- values:
-
- For 120 quarters (30 years), key in "120N".
- For 12% interest rate (APR), key in "12I".
- For $500 payment to the account, key in "500~P". Remember
- our point of view. This is an outgoing payment.
- The present value is 0, so the S register is OK.
- To compute the future value, key in "T". WOW!! Don't you
- wish you had started this 30 years ago? You might
- have had $561,849.79 by now.
-
- There are many financial situations that fit this pattern. Remember
- that the number of periods and interest rate are always positive.
- Negative values have no sensible interpretation. Present value, future
- value, and periodic payment are either positive or negative depending
- on whether cash is flowing to you or away from you. The correct sign
- for the known values must be entered for the calculation to work
- correctly. The sign of a computed answer tells the direction of cash
- flow.
-
- MACROS
-
- The program's macro capability allows you to define sequences of
- keypokes which will be remembered by the program and executed on
- demand. There are 11 macro storage strings defined. Ten of these are
- used to hold macros assigned to the 10 function keys. The 11th is a
- scratch area which is used for initial definitions, macro execution,
- and macro editing.
-
- There are two ways within the program to define a macro string. The
- first is the "\m" operation which starts collecting and remembering
- keypokes as you actually execute them on the calculator. This
- collection process will continue until you fill up the macro storage
- string (76 characters) or until you enter the "\m" keys a second time
- to signal the end of the macro entry. The status line near the top of
- the screen will tell you when macro definition is in progress. In this
- macro entry mode there can be no backing up to correct mistakes.
-
- The second way to define a macro string is with the macro editor, which
- is capable of examining and modifying the scratch string and assigning
- its contents to one of the 10 function keys. The macro editor is
- entered by the "M" key and exited either by a second use of the "M" key
- or by use of one of the function keys. Use of "M" to exit the editor
- leaves the edited macro in the scratch string where it can be executed
- with "m". Use of a function key to exit the editor causes the edited
- macro to be copied from the scratch storage to the string assigned to
- the function key.
-
- When entered, the macro editor will display the macro currently
- resident in the scratch area. This may be the macro just entered with
- "\m", or the last macro executed by a function key, or it may be empty.
- You may edit the macro with the following edit keys:
-
- cursor left ---- non destructive left cursor motion
- cursor right --- non destructive right cursor motion
- home ----------- moves cursor to beginning of line
- end ------------ moves cursor to end of line
- delete --------- deletes character the cursor is currently on
- backspace ------ deletes character before the cursor position
-
- Printing characters in the range from "!" to "~" are inserted into the
- line before the current cursor position. Characters outside this
- range, except for the edit keys, are ignored. Aside from excluding
- non-printing characters and limiting macro size the editor makes no
- tests on the validity of the characters you enter so you are
- responsible for the logic and executability of the changes you make.
-
- To edit a macro assigned to a function key, it is necessary to move it
- to the scratch string. This happens when the macro is executed by
- poking its function key. To move it without execution, poke the "\"
- key followed by the function key. Then use "M" to enter the editor.
-
- Brief comments may be inserted in macro strings by enclosing them in
- square brackets. This may be useful if you are going to save macros in
- a disk file but the comment uses up macro keypokes. Here are some
- sample macros (in RPN) to do the Fahrenheit to Centigrade and
- Centigrade to Fahrenheit conversions:
-
- [C to F]=9=5/*32+
- [F to C]=32-5=9/*
-
- Notice in the RPN macros above the uses of the ENTER key are stored as
- equals signs. Inside the calculator all the keys (space, newline,
- return, and =) which are interpreted as ENTER are converted to the
- equals sign, partly because it is the only printing character of the
- group and partly because it makes sense in algebraic mode where the
- same set of keys is used as EQUALS.
-
- The same calculations as they could be entered as a macro in algebraic
- mode would look like this:
-
- [C to F]*9/5+32=
- [F to C]-32*5/9=
-
- Normally, execution of a macro proceeds exactly as if the characters
- from the macro string were being entered from the keyboard. The values
- contained in the stack on exit from the macro will be those left from
- the calculations in the macro and will likely be different from the
- values on entry. In many cases this makes no difference and in fact
- may be desirable. Perhaps just as often, however, it is desirable to
- write a macro to do some sort of a conversion or other function and
- return a value to the x register much as the built-in functions such as
- log and square root do. In such a function, you would prefer not to have
- the stack altered by the macro (except for the x register, of course).
-
- The macro function flag (#) character, inserted at the beginning of a
- macro, indicates that the macro is to be treated as a function returning
- a result to the x register. This causes the y, z, and t registers to
- be saved while the macro is executing and restored when the macro ends.
- Whatever the macro leaves in the x register is assumed to be the result
- and is left there. Also the flags that control processing of input are
- set to indicate that a new number input is expected (in other words,
- any number entry in progress when the macro terminates is ended as if
- the ENTER key had been poked). In algebraic mode, a pending operation
- is saved and restored at the end of the macro execution, allowing the
- result of a macro function to be included in a chain calculation.
-
- For example, if you put the radius of a circle in the x register, a
- macro to find the area of the circle wuold be "\q*p=" in algebraic mode.
- If you enter this and execute it, you'll see that it changes the y register.
- A little further experimentation will show that the result can't be used
- in a chain calculation except at the beginning. Now change the macro so
- it is "#\q*p=" and try again. Now executing the macro saves y when the
- "#" is encountered and restores it when the macro finishes. It also saves
- any pending operation and propogates it across the macro so you can do
-
- 1+2.5m+4m=
-
- and get the right answer. It is algebraic mode where this is really
- necessary. In RPN mode you can get along without this because the problem
- of remembering pending operations does not exist, but it still can be
- handy to preserve the contents of the y, z, and t registers through
- macro execution.
-
- By the way, I realize that the next extension of this is to allow a macro
- to use another macro and that may happen in a later revision but is not
- handled now.
-
- SAVING MACROS IN A DISK FILE
-
- The macros assigned to function keys may be saved in a disk file and
- restored whenever the program is executed. Up to 10 sets of macros may
- be saved in RPN mode and 10 more in algebraic mode (RPN and algebraic
- macros are not interchangable, hence separation of macro files). The
- file names are of the format RPN.R0 to RPN.R9 for RPN macros and RPN.A0
- to RPN.A9 for algebraic macros. The "\M" function will ask you for a
- digit from 0-9 to specify the file number and then will write the
- macros in the appropriate file, creating the file if necessary or
- overwriting an existing file.
-
- When the program is executed it looks by default for macro file 0. You
- can specify which file you want it to load by a 0 to 9 digit in the
- first parameter. For example, the following will attempt to find and
- load macros from RPN.R4.
-
- RPN R4
-
- The macro file is clear text and as such can be changed with a text
- editor. Be careful not to disturb the file structure if you try this.
- The format of the macro save file is:
-
- The color attributes: (comment line)
- - -
- (14 lines containing color attributes)
- - -
- The function key macros for F1-F10: (comment line)
- - -
- (10 lines containing macro definitions)
- - -
- End of file. (comment line)
-
- CHANGING SCREEN COLORS
-
- If you feel like experimenting with screen colors, you can do it
- without recompiling the program. The screen colors used are written
- out to the macro file and can be changed by a text editor. When a
- macro file is loaded during program initialization, the colors stored
- in the macro file will override the defaults in the program. The
- defaults, in the order they are written are:
-
- 15 --- Title color (normal & memory mode)
- 13 --- Status color (normal & memory mode)
- 14 --- Register color (normal & memory mode)
- 12 --- Message color (normal & memory mode)
- 3 ---- Help color (normal & memory mode)
- 0 ---- Background color (normal & memory mode)
- 0 ---- Border color (normal & memory mode)
- 15 --- Title color (financial & summation mode)
- 13 --- Status color (financial & summation mode)
- 14 --- Register color (financial & summation mode)
- 10 --- Message color (financial & summation mode)
- 3 ---- Help color (financial & summation mode)
- 0 ---- Background color (financial & summation mode)
- 0 ---- Border color (financial & summation mode)
-
- Following the color data are the macros, and the final line says "End
- of file".
-
- ERROR MESSAGES
-
- The calculator will eventually be told to do something that it can't
- do. If I haven't thought of it in advance you may get an error from
- the floating point routines and possibly get kicked out of the program
- or get incorrect results.
-
- If I have thought of it in advance, you will probably get beeped at and
- get an error message on the message line of the screen. The error
- messages defined currently are:
-
- "Divide by zero."
- The denominator of an "o", "/" or "%" function is 0.
-
- "Illegal argument."
- From "%" when the argument is too large or not an integer. From "!",
- "&", "|", and "$" if the argument is not an integer.
-
- "Overflow."
- From factorial if the argument is greater than 170.
-
- "Valid in decimal only."
- From enter exponent if the number base is not 10.
-
- "Illegal during macro definition."
- Macros are not recursive so it's illegal to hit "m" or a macro function
- key during a macro definition phase. It's also illegal to enter the
- macro editor during macro definition.
-
- "Macros not recursive."
- If this happens, an "m" was encountered during a macro execution. It
- was probably entered into the macro during an edit session.
-
- "Macro not defined."
- This happens when a macro execution or copy is requested and the macro
- definition is found to be empty.
-
- "Did not converge."
- This means that the interest rate calculation in financial mode did not
- converge to an answer in a reasonable number of iterations. Make sure
- you are asking it to do something reasonable.
-
- "Does not compute."
- This error is the result of one of several tests for gotchas during any
- of the financial computations. What it generally means is that the
- data in the financial registers is inconsistent and an answer can't be
- computed. An example of this is the attempt to compute a number of
- payments necessary to pay off a loan when the periodic payment
- specified is less than or equal to the periodic interest on the loan.
-
- "Floating point domain error."
- This is from an error code set by a floating point routine when it
- gets input which is invalid for the function being computed.
- Example: Arcsin or arccos of a value greater than 1.
-
- "Floating point range error."
- This is from another error code set by a floating point routine when
- a calculation results in overflowing the range of numbers the
- computer can represent internally. Example: exp(695)
-
-
- -------------------------
- In this document I have made reference to the following:
- IBM PC, PC jr, and PC-DOS are trademarks of IBM Corp.
- MS is a trademark of Microsoft.
- Sidekick is a trademark of Borland International
-